<template>
  <div id="AsnDetail">
    <component
      :inputData="detailData"
      :is="currentComponent"
    ></component>
  </div>

</template>

<script>
import detail from "commons/Detail";
import baseMixin from "@/mixins/BaseMixin";

export default {
  name: "AsnDetail",
  mixins: [baseMixin],
  data () {
    return {
      newFlag: false,
      selectData: {},
      detailData: {
        allocatestrategykey: " ",
        descr: " ",
        allocatestrategytype: "1",
        retryifqtyremain: "0"
      },
      detailNav: "1",
      componentConfig: [
        {
          name: "Common",
          label: this.$t('config.general'),
          component: () => import('./page/particulars.vue')
        }
      ]
    }
  },
  computed: {
    currentComponent () {
      return this.componentConfig[this.detailNav - 1].component;
    }
  },
  methods: {
    async getData () {
      try {
        let res = await this.$api.get(`querybyallocatestrategy12/${this.selectData.allocatestrategykey}`);
        
          this.detailData = res.bean;
          this.detailData.retryifqtyremain = this.detailData.retryifqtyremain + '';
        
      } catch (e) {
        this.$message.error(e);
      }
    },
  },
  mounted () {
    this.newFlag = this.$store.state.newFlag;
    if (Object.keys(this.$store.state.skip).length !== 0) {
      let data = this.$store.state.skip;
      this.detailData = data.detail;
      this.selectData = data.routeData;
      this.detailNav = data.detailNav;
      this.newFlag = data.newFlag;
      this.$store.commit("setNewFlag", data.newFlag);
    } else if (!this.newFlag) {
      this.selectData = this.$store.state.routeData;
      this.getData();
    }
  },
  components: {
    "v-detail": detail,
  },

}
</script>

<style scoped>
</style>
